package com.tw.management.repository;

import java.util.Date;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.tw.management.entity.User;

/**
 * 
 * @author TangW
 * @version 1.0
 *
 */
public interface UserDao extends JpaRepository<User, Long> {

	public User findUserByEmail(String email);

	public User findUserByEmailAndPassword(String email, String passwrod);

	public User findUserById(Long id);

	@Modifying
	@Query("update sys_users u set u.realname = ?1,u.gender= ?2,u.birthDate= ?3,u.mobile= ?4 where u.id = ?5")
	public int updateUserInfo(String realname, String gender, Date bitrhDate, String mobile, Long id);

	@Modifying
	@Query("update sys_users u set u.password = ?1 where u.id = ?2")
	public int updateUserPassword(String password, Long id);

}
